#ifndef SETTINGDIALOG_H
#define SETTINGDIALOG_H

#include <QObject>
#include <QDialog>
#include <QIcon>
#include <QPushButton>
#include <QLabel>
#include <QGroupBox>
#include <QGridLayout>
#include <QRgb>
#include <QComboBox>
#include <QColorDialog>
#include <QPixmap>
#include <QColor>
#include <QComboBox>
#include <QLineEdit>
#include <QTextEdit>
#include <QTextStream>
#include <QFileDialog>
#include <QMessageBox>
#include <QDebug>
#include <QCoreApplication>
class SettingDialog : public QDialog
{
    Q_OBJECT
public:
    explicit SettingDialog(QDialog *parent = 0);
    QRgb rgb_lav,rgb_rav,rgb_liav,rgb_riav; //left/right avaliable/inavaliable
    void setcolor();
    void setCurrentName(int n,QString t)
    {
        currentName[n] = t;
        nameEdit0[n]->setText(t);//并没有什么卵用？
    }
    void setCurrentSize(int w,int h)
    {
        if (w==80&&h==60)
        {
            setScale->setCurrentIndex(1);
        }
        if (w==160&&h==120)
        {
            setScale->setCurrentIndex(0);
        }
    }

    int getCurrentSize()
    {
        return setScale->currentIndex();
    }

    QString getCurrentName(int n)
    {
        currentName[n] = nameEdit0[n]->text();
        return currentName[n];
    }
    void setCurrentBitName(int n,QString t)
    {
        currentBitName[n] = t;
            bitEdit[n]->setText(t);
    }
    QString getCurrentBitName(int n)
    {
        currentBitName[n] = bitEdit[n]->text();
        return currentBitName[n];
    }
    QString loadFileName = "Config.ini";
    void loadDefault();
    ~SettingDialog();
private:
    QString saveFileName;//loadFileName;
    QGroupBox *Box0,*Box1,*bitBox;
    QGridLayout *setNameLayout,*bitLayout;
    QComboBox *setScale;
    QLabel *scaleLabel,*bitLabel[8];
    QGridLayout *Layout0;
    QPushButton *l_av,*r_av,*l_iav,*r_iav;
    QLabel *bl_av,*br_av,*bl_iav,*br_iav;
    QImage *i_lav,*i_rav,*i_riav,*i_liav;
    QString currentName[5],currentBitName[8];
    //"确定""取消""恢复默认"
    QPushButton *yes,*no,*def,*apply;
    QLabel *nameLabel[5];
    //QLineEdit *nameEdit[5];
    QLineEdit *nameEdit0[5],*bitEdit[8];
    //返回默认值
    QPushButton *defaultButton,*loadFile,*saveFile;
signals:
    void setColor(int n);
    void shouldChange();
public slots:
    void set1(){emit setColor(1);}
    void set2(){emit setColor(2);}
    void set3(){emit setColor(3);}
    void set4(){emit setColor(4);}
    void emitChange(){emit shouldChange();}
    void setDefault();
    void settingColor(int n)
    {
        QRgb trgb ;
        QColor tclor;
        tclor = QColorDialog::getColor();
        trgb = tclor.rgb();
        switch(n)
        {
        case 1:
            rgb_lav = trgb;
            break;
        case 2:
            rgb_rav = trgb;
            break;
        case 3:
            rgb_liav = trgb;
            break;
        case 4:
            rgb_riav = trgb;
            break;
        }
        setcolor();
        this->repaint();
    }
    void load();
    void save();

};

#endif // SETTINGDIALOG_H
